var AbstractList = Class.create({
  initialize:function(args)
  {
    this.callBack = args.call_back;
    this.url = args.url;
    this.filter = args.filter;
    if(args.params)
    {
      this.params = args.params;
    }
    else
    {
      this.params = new Object();
    }
    this.loadData();
  },
  loadData:function()
  {
    this.params.tmpid = new Date().getTime();
    var a = new Ajax.Request(
        this.url,
        {
            "method": "get",
            "parameters":$H(this.params).toQueryString(),
            onSuccess: function(request) {
              this.dataSet = request.responseText.escapeHTML().evalJSON(true);
              if(this.filter)
              {
                this.filterData(this.filter);
              }
              else
              {
                this.createDataSet(this.dataSet);
              }
            }.bind(this),
            onFailure: function(request) {
                alert('読み込みに失敗しました');
            },
            onException: function (request) {
                alert('読み込み中にエラーが発生しました');
            }
        }
    );
  },
  filterData:function(args)
  {
      var dataSet = [];
      for(var i=0;i<this.dataSet.length;i++)
      {
        var data = this.dataSet[i];
        var matchFlg = true;
        for(var j=0;j<args.length;j++)
        {
          if(data[args[j].item].constructor == Array)
          {
            if(!data[args[j].item].include(args[j].value))
            {
              matchFlg = false;
              break;
            }
          }
          else
          {
            if(data[args[j].item] != args[j].value)
            {
              matchFlg = false;
              break;
            }
          }
        }
        if(matchFlg)
        {
          dataSet.push(this.dataSet[i]);
        }
      }
      this.createDataSet(dataSet);
  }
});
